Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chat component #87

Merged
merged 3 commits into from
Feb 4, 2023
Merged

chat component #87

merged 3 commits into from
Feb 4, 2023

Conversation

AbhimanyuAryan
Copy link
Member

[❌] - don't merge

Bug: don't render text message

@AbhimanyuAryan
Copy link
Member Author

#88

@hhaensel
Copy link
Member

hhaensel commented Feb 3, 2023

Is fixed now :-)

@hhaensel
Copy link
Member

hhaensel commented Feb 3, 2023

I chose to render String and Vector{String} arguments directly.
That means if you want to use a string field you have to reference it as a vector

@app begin
  @out textmsg1 = ["hey, how are you?"]
  @out textmsg2 = "I am good"
end

function ui()
  [
    Html.div(class="q-pa-md row justify-center",[
      Html.div(style="width: 100%; max-width: 400px",[
        chatmessage("This is static text", name="abhi", sent = true)
        chatmessage(:textmsg1, name="abhi", sent = true)
        chatmessage(Symbol("[textmsg2]"), name="adrian")
      ])
    ])
  ]
end

@hhaensel
Copy link
Member

hhaensel commented Feb 3, 2023

If you are ok with this syntax, let's merge. 🚀

@hhaensel
Copy link
Member

hhaensel commented Feb 3, 2023

A chat app would rather apply a Vector of Dict for a chat window, e.g. like this

using Random

using GenieFramework
@genietools

@app begin
  @in addpost = false
  @out chat = Dict{Symbol, Any}[]

  @onbutton addpost begin
    push!(chat, Dict(:text => [randstring(10) for i in 1:rand(1:3)], :name => randstring(5), :sent => Bool(rand(0:1))))
    notify(chat)
  end
end

function ui()
  [
    cell(class = "st-module q-ma-md q-pa-md", [
        btn("Add message", @click(:addpost), icon = "mail")
        chatmessage(R"d.text", name = R"d.name", sent = R"d.sent", "", @recur("d in chat"))
    ])
  ]
end

p = @page("/", ui)

Server.isrunning() || Server.up()

@AbhimanyuAryan
Copy link
Member Author

@hhaensel you thought of everything. I don't have anything to add to it. I didn't think of adding Dict case with loop. This is perfect. I'll merge

@AbhimanyuAryan
Copy link
Member Author

oh and just realized all our stippleui docs is now using deprecated syntax @reactive :(

maybe I need do entire dir look up with Regex

@reactive! mutable struct xxxxxxx <: xxxxx   # <--- find this pattern in all files
   # code
end

replace this with

@vars begin  # <---- replace with pattern
   # code
end

that would be easiest. Adding

@app begin
@out ___
@out ___
end

would require manual updating however :(

@AbhimanyuAryan
Copy link
Member Author

Ok no. Even the properties field have ugly R types

valone::R{Bool} = true. Will require manual updating :(

@hhaensel
Copy link
Member

hhaensel commented Feb 4, 2023

But @vars supports both gold old R-type syntax and a modernised one where you don't specify R. Instead you add NON_REACTIVE at the end if the fields should be a simple bare type.
Since the overhaul of the ReactiveModel type these fields can also be readonly or private etc. But update needs to be done manually.

@AbhimanyuAryan
Copy link
Member Author

R_str ❤️

@AbhimanyuAryan AbhimanyuAryan merged commit 4eb578b into master Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants